package com.ruoyi.project.treat.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.treat.domain.TreDepts;
import com.ruoyi.project.treat.service.ITreDeptsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/treat/depts")
public class TreDeptsController extends BaseController {
    @Autowired
    private ITreDeptsService treDeptsService;

    //查询所有科室
    @RequestMapping("/all")
    public AjaxResult getDeptsAll(){
        return AjaxResult.success(treDeptsService.findDeptsAll());
    }

    //根据科室名称查找科室信息
    @GetMapping("/{deptsName}")
    @PreAuthorize("@ss.hasPermi('treat:register:index')")
    public TableDataInfo getByName(@PathVariable String deptsName){
        System.out.println(deptsName);
        List<TreDepts> list = treDeptsService.findByName(deptsName);
        System.out.println(deptsName);
        return getDataTable(list);
    }
}
